#include<bits/stdc++.h>
using namespace std;
int n, m, x, y;
int ans;
int total, traveled;
int dx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
bool vis[15][15];
void dfs(int a, int b) {
  if(total==traveled) {
    ans++; return;
  }
  for(int i=0; i<8; ++i) {
    int nx=a+dx[i], ny=b+dy[i];
    if(nx<0 || ny<0 || nx>=n || ny>=m || vis[nx][ny]) continue;
    vis[nx][ny] = true; traveled++;
    dfs(nx, ny);
    vis[nx][ny] = false; traveled--;
  }
}
void solve() {
  total = n*m;
  traveled = 1;
  ans = 0;
  memset(vis, 0, sizeof(vis));
  vis[x][y] = true;
  dfs(x, y);
  cout<<ans<<'\n';
}
int main() {
  int T; cin>>T;
  while(T--) cin>>n>>m>>x>>y, solve();
}
